package day1.url;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/day1/url/servlet")
public class Url extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name=req.getParameter("name");
        req.getSession().setAttribute("name",name);
        String id=req.getSession().getId();
        System.out.println("id="+id);
        //resp.sendRedirect(resp.encodeURL("/day1/url/2.jsp"));
        resp.sendRedirect("/day1/url/2.jsp"+";jsessionid="+id);
    }
}
